#!/bin/bash

# Read the user's configured font size
profile=$(gsettings get org.gnome.Terminal.ProfilesList default)
font_size=$(gsettings get org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$profile/ font)

# Extract the font size value
font_size=$(echo "$font_size" | grep -oP '\d+')

# Calculate the width and height of each terminal window
display_resolution=$(xrandr | grep -oP '\d+x\d+' | head -n 1)
desktop_width=$(echo "$display_resolution" | cut -d 'x' -f 1)
adjusted_width=$((desktop_width - (font_size * 5 / 10))) # Convert centimeters to pixels
window_height=$((font_size * 24))

# Open a terminal window with the calculated dimensions
gnome-terminal --geometry="${adjusted_width}x${window_height}"

